<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>陪你晒郑州</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="//static1.finchain.cc/lib/layui/v1.0.9_rls/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="http://s10.realdtech.com/tongpin/pns-zhengzhou/css/style.css"/>
		<script src="http://s10.realdtech.com/tongpin/pns-zhengzhou/js/jquery-1.9.1.js"></script>
	</head>
	<body>
		<div class="banner">
			<img src="http://s10.realdtech.com/tongpin/pns-zhengzhou/img/banner.png">
		</div>
		<div class="house-form">
			<form class="layui-form" action="">
			<input name="id" value="#(id??)" type="hidden"/>
			<div class="layui-form-item">
				<label class="layui-form-label">姓名：</label>
				<div class="layui-input-block">
					<input type="text" name="name" required lay-verify="required" id="name" placeholder="请输入您的姓名" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">电话：</label>
				<div class="layui-input-block">
					<input type="text" name="tel" required lay-verify="required" id="tel" placeholder="请输入您的联系方式" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">购房目的：</label>
				<div class="layui-input-block">
					<select name="purchase" lay-filter="linkType">
						<option value="">请选择您的购房目的</option>
						<option value="刚需自住">刚需自住</option>
						<option value="改善置换">改善置换</option>
						<option value="改换使用">改换使用</option>
						<option value="其它">其它</option>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">意向区域：</label>
				<div class="layui-input-block">
					<input type="text" name="intention.area"  readonly="readonly" placeholder="请点击选择您的意向区域" autocomplete="off" id="shengshi" onClick="getProvinceBuy()" class="layui-input address_input1">
					<i class="layui-edge"></i>
				</div>
				<div class="body"></div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">意向楼盘：</label>
				<div class="layui-input-block">
					<input type="text" name="intention.building" placeholder="请输入您的楼盘意向" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn layui-btn-disabled" id="submit" disabled="disabled" lay-submit="" lay-filter="submit">立即提交</button>
					<p>我们客服人员会第一时间跟您取得联系</p>
				</div>
			</div>
		</form>
		</div>
	</body>
	<script src="//static1.finchain.cc/lib/layui/v1.0.08/layui.js"></script>
	<script type="text/javascript" src="//static1.finchain.cc/lib/easyui/v1.5.1/jquery.min.js"></script>
	<script src="//admin.static1.finchain.cc/js/common.js"></script>
	<script>
		layui.ready(['layer', 'form','layedit'], function() {
				var form = layui.form(),
					$ = layui.jquery;
				$("#name").keyup(function() {
					isshenqing();
				})
				$("#tel").blur(function(e) {
					if (!/^1((3|5|7|8){1}\d)\d{8}$/.test($("#tel").val())){ 
						layer.msg("请输入正确的手机号");
//						return false;
					}
					
						
						console.log($("#tel").val());
                    isshenqing();
				});
				var isshenqing = function() {
					if ($("#name").val() != "" && $("#tel").val() != ""  && /^1((3|5|7|8){1}\d)\d{8}$/.test($("#tel").val())  ) { 
						$("#submit").addClass("layui-btn-disabled").removeAttr("disabled","true").addClass("layui-btn-normal");
					} else {
						$("#submit").addClass("layui-btn-disabled").attr("disabled", "true").removeClass("layui-btn-normal");
					}
				}
		
				//监听提交
				form.on('submit(submit)', function(data) {
					layer.load(1);
					setTimeout(
						function() {
							$.ajax({
								type: "post",
								url: "/house/submit",
								data: data.field,
								dataType: 'json',
								success: function(result) {
									//关闭弹出框
//									parent.layer.close(index);
                                    window.location.href="../house/success";
								},
								error: function() {
									layer.alert('请求失败', {
										icon: 2,
										title: '提示'
									});
								},
								complete: function() {
									layer.closeAll('loading');
								}
							});
						}, 2000);
					return false;
				});
			});
			
			
			/**
 * 地区联动
 * */
function getProvinceBuy(){
$(".body .dqld_div").remove();
	var province=eval(proStr);
	var newStr=new Array();
	newStr.push("<div class=\"dqld_div\" style=\"\"><ul>");
	for(var i=0,psize=province.length;i<psize;i++){
		province[i].NAME;
		newStr.push("<li onclick=\"getCityBuy("+i+")\">"+province[i].NAME+"</li>");
	}
	newStr.push("</ul></div>");
	$(".body").append(newStr.join(""));
}

function getCityBuy(val){
	var province=eval(proStr);
	var city=eval(province[val].ITEMS);
	var newStr=new Array();
	newStr.push("<div class=\"dqld_div\"><ul>");
	newStr.push("<li onclick=\"getProvinceBuy()\" style=\"background-color:#fff;color:#3366cc;\">"+province[val].NAME+"</li>");
	for(var j=0,csize=city.length;j<csize;j++){
		newStr.push("<li onclick=\"getAreaBuy("+j+","+val+")\"  style=\"padding-left:20px;\">"+city[j].NAME+"</li>");
	}
	newStr.push("</ul></div>");
	$(".body .dqld_div").remove();
	$(".body").append(newStr.join(""));
}

function getAreaBuy(val,val1){
	var province=eval(proStr);
	var city=eval(province[val1].ITEMS);
	var area=eval(city[val].ITEMS);
	var newStr=new Array();
	newStr.push("<div class=\"dqld_div\"><ul>");
	newStr.push("<li onclick=\"getProvinceBuy()\" style=\"color:#3366cc;\">"+province[val1].NAME+"</li>");
	newStr.push("<li onclick=\"getCityBuy("+val1+")\" style=\"color:#3366cc;padding-left:10px;\">"+city[val].NAME+"</li>");
	for(var t=0,asize=area.length;t<asize;t++){
		area[t].NAME;
		newStr.push("<li  style=\"padding-left:25px;\" onclick=\"getallArea("+val1+","+val+","+t+")\">"+area[t].NAME+"</li>");
	}
	newStr.push("</ul></div>");
	if(asize==0){
		var allarea=province[val1].NAME+" "+city[val].NAME;
		$("#shengshi").attr({"SS":province[val1].NAME,"SQ":city[val].NAME,"XS":""});
		$("#shengshi").val(allarea);
		$(".body .dqld_div").remove();
	}
	else{
		$(".body .dqld_div").remove();
		$(".body").append(newStr.join(""));
	}
}

function getallArea(val,val1,val2){
	var province=eval(proStr);
	var city=eval(province[val].ITEMS);
	var area=eval(city[val1].ITEMS);
	var allarea=province[val].NAME+" "+city[val1].NAME+" "+area[val2].NAME;
	$("#shengshi").attr({"SS":province[val].NAME,"SQ":city[val1].NAME,"XS":area[val2].NAME});
	$("#shengshi").val(allarea);
	$(".body .dqld_div").remove();
}
/*地区联动*/
	</script>
</html>
